--select * into passeg_old from passeg

declare @tmp table( codpren varchar(14), n_mod int)
insert into @tmp select p.codpren, e.n_mod from passeg p inner join 
	entbig e on e.codpren=p.codpren
	where p.n_mod is null group by p.codpren, e.n_mod

declare @n_mod int, @codpren varchar(14)
declare cursore cursor for select codpren, n_mod from @tmp
open cursore
fetch next from cursore into @codpren, @n_mod
while @@fetch_status=0
begin
	update passeg set n_mod=@n_mod where codpren=@codpren
	fetch next from cursore into @codpren, @n_mod
end
close cursore
deallocate cursore

--select * from passeg where n_mod is null

